package com.example.demo;

import java.lang.ref.WeakReference;

public class WeakReferenceTest {
    public static void main(String[] args) {
        WeakReference<M> m = new WeakReference<>(new M());
        System.out.println(m.get());
        System.gc();
        try {
            Thread.sleep(10*1000L);
        }catch (Exception e){
            e.printStackTrace();
        }
        System.out.println(m.get());
    }
}
